<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="students/css/font-awesome.min.css" rel="stylesheet" type="text/css" media="all" />
    <link href="students/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="all" />
    <link href="students/css/chromagallery.css" rel="stylesheet" type="text/css" media="all" />
    <link href="students/css/style.css" rel="stylesheet" type="text/css" media="all" />
    <link href="students/css/project-center.css" rel="stylesheet" type="text/css" media="all" />
    <title>项目中心</title>
</head>

<body>
    <?php
    session_start(); 
    require_once("./congfig/config.php");
    $sql = "select * from proinfor";
    $query = $GLOBALS['conn']->query($sql);
    $num = $query->num_rows;
    $pagesize = 7;
    $page = empty($_GET['page']) ? 1 : $_GET['page'];
    $prepage = $page - 1;   
    $nextpage = $page + 1;   
    $tatolpage = ceil($num / $pagesize);   
    $startpage = ($page - 1) * $pagesize;   
    @$key = $_GET['key'];   
    if (isset($key)) {     $sql = "select * from proinfor where pName like '%$key%'";     $query = $GLOBALS['conn']->query($sql);   }
     else {     $sql = "select * from proinfor  LIMIT $startpage,$pagesize ";     
     $query = $GLOBALS['conn']->query($sql);     // $result=$query1->fetch_array();     // echo $result['pName'];   }
 }


     ?>
    <div class="navbar-wrapper">
        <div class="container">
            <nav class="navbar navbar-inverse navbar-static-top cl-effect-21">
                <div class="container">
                    <div id="navbar" class="navbar-collapse collapse">
                        <ul class="nav navbar-nav">
                            <li><a href="index.php">首页</a></li>
                            <li class="active"><a href="#">项目中心</a></li>
                            <li><a href="project-teacher.php">指导教师</a></li>
                            <li><a href="#About Us">关于我们</a></li>
                            <li><?php 
                            if (!isset($_SESSION['rank'])) {  ?>
                                <a href="login.php" style="font-size:13px;margin-left: 100px;">登陆/注册</a>
                            <?php  
                             }
                             elseif ($_SESSION['rank']==0){ ?>
                             <a href="students/owner-myProject.php" style="font-size:13px;margin-left: 100px;">学生：个人中心</a>
                            <?php 
                            }
                             
                             elseif ($_SESSION['rank']==1){ ?>
                             <a href="teacher/project-list.php" style="font-size:13px;margin-left: 100px;">老师：个人中心</a>
                            <?php 
                            }
                             
                             elseif ($_SESSION['rank']==2){ ?>
                             <a href="admin/project-list.php" style="font-size:13px;margin-left: 100px;">管理员中心</a>
                            <?php 
                            }
                             ?>
                                
                            </li>
                        </ul>
                    </div>
                </div>
            </nav>
        </div>
        <!-- 项目列表 -->
        <?php 
         $sql1="select * from proinfor";
         $result1=$conn->query($sql1);
         ?>
        <div class="container">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">项目中心</h3>
                </div>
                
                <table class="table">
                    <thead>
                        <tr>
                            <th>编号</th>
                            <th>项目名称</th>
                            <th>指导教师</th>
                            <th>项目负责人</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
                        $i=1;
                        while ($row1=$query->fetch_array()) {
                            ?>
                            <tr>
                            <td><?php echo $i++; ?></td>
                            <td><?php echo $row1["pName"]; ?></td>
                            <td><?php echo $row1["teacher"]; ?></td>
                            <td><?php echo $row1["pChar"]; ?></td>
                            <td><a href="project-content.php?pid=<?php echo $row1['id'] ?>"  target="_blank" class="btn btn-default">查看</a></td>
                        </tr>
                        <?php }
                         ?>
                        
                        <?php             if ($prepage <= 0) {               $prepage = 1;             }             if ($nextpage > $tatolpage) {               $nextpage = $page;             }             ?>               <?php           if ($prepage < 0) {             $prepage = 0;           }           if ($nextpage > $tatolpage) {             $nextpage = $page;           }           ?>


                        <tr>
                            <td align="1enter" colspan="8" class="page">
                                <!-- 分页开始 -->
                                <ul class="pagination">
                                    <li><a href="project-center?page=0"><i class=" fa fa-fast-backward"></i></a></li>
                                    
                                    <li><a href="project-center?page=<?php echo($prepage) ?>"><i class="fa fa-backward"></i></a></li>
                                    <li class="gray" >
                                           <span>第 <?php echo($page) ?>页</span>  
                                     </li>
                                    <li><a href="project-center?page=<?php echo($nextpage) ?>"><i class=" fa fa-forward"></i></a></li>
                                    
                                    <li><a href="project-center?page=<?php echo($tatolpage) ?>"><i class=" fa fa-fast-forward"></i></a></li>
                                </ul>
                                <!-- 分页结束 -->
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- 项目列表 end-->

        <!-- 底部兰 -->
        <section class="footer" id="About Us" style="margin-top:200px;width: 100%;">
            <h2 class="text-center">THANKS FOR VISITING US</h2>
            <hr>
            <div class="container">
                <div class="row">
                    <div class="col-md-4  col-md-offset-4">
                        <div class="contact-info">
                            <div class="phone">
                                <i class="glyphicon glyphicon-phone-alt"></i>
                                <p class="p4">+00 1010101010</p>
                            </div>
                            <div class="email-info">
                                <i class="glyphicon glyphicon-envelope"></i>
                                <p class="p4">469902XXX@qq.com </p>
                            </div>
                        </div>
                    </div> 
                </div> 
            </div> 
            <hr>
            <div class="copyright">
                <p>Copyright &copy; 2018.徐志摩 </p>
            </div>
        </section>
        <!-- 底部兰 end-->
    </div>
</body>

</html>